import 'dart:convert';

import 'package:bilibili/http/request/base_request.dart';

///网络请求抽象类
abstract class SunNetAdapter<T> {
  Future<SunNetResponse<T>> send<T>(BaseRequest request);
}

///统一网络层返回
class SunNetResponse<T> {
  T? data;
  BaseRequest? request;
  int statusCode;
  String? statusMessage;
  dynamic extra;

  SunNetResponse(
      {this.data,
      this.request,
      this.statusCode = -1,
      this.statusMessage,
      this.extra});

  @override
  String toString() {
    if (data is Map) {
      return json.encode(data);
    }
    return data.toString();
  }
}
